package reduce.fz.com.reduce.service;

import android.content.Context;

import org.apache.http.params.HttpParams;

import java.util.HashMap;

import reduce.fz.com.reduce.R;
import reduce.fz.com.reduce.abstracts.AbResponseListener;
import reduce.fz.com.reduce.bean.SubjectReply;
import reduce.fz.com.reduce.bean.Suggestion;
import reduce.fz.com.reduce.bean.TargetSet;
import reduce.fz.com.reduce.bean.Team;
import reduce.fz.com.reduce.bean.TeamSubject;
import reduce.fz.com.reduce.bean.WitnessCard;
import reduce.fz.com.reduce.util.ApiUtil;
import reduce.fz.com.reduce.util.HttpUtils;
import reduce.fz.com.reduce.util.base.ReduceApplication;

/**
 * Created by qingshengzheng on 15/11/11.
 */
public class TeamService {
    private Context context;

    public TeamService(Context context) {
        //this.context = context;
        this.context = ReduceApplication.getInstance().getBaseContext();
    }

    public void loadTeamDetail(Long teamid, AbResponseListener listener) {
        String url = ApiUtil.getApi(context, R.array.api_team_detail, teamid);
        HttpUtils.get(url, listener);
    }

    public void loadTeamDynamics(Long teamid, AbResponseListener listener) {
        String url = ApiUtil.getApi(context, R.array.api_team_dynamic_list, teamid);
        HttpUtils.get(url, listener);
    }

    public void joinTeam(Long teamid, AbResponseListener listener) {
        String url = ApiUtil.getApi(context, R.array.api_team_join, teamid);
        HashMap map = new HashMap();
        HttpUtils.post(url, map, listener);
    }

    public void quitTeam(Long teamid, AbResponseListener listener) {
        String url = ApiUtil.getApi(context, R.array.api_quit_team, teamid);
        HashMap map = new HashMap();
        HttpUtils.post(url, map, listener);
    }

    public void getSuggestion(Long teamid, AbResponseListener listener) {
        String url = ApiUtil.getApi(context, R.array.api_team_suggestion, teamid);
        HttpUtils.get(url, listener);
    }


    public void pubSubject(TeamSubject subject, AbResponseListener listener) {
        String url = ApiUtil.getApi(context, R.array.api_team_pub_subject, subject.teamid);
        HashMap map = new HashMap();
        map.put("desc", subject.description);
        HttpUtils.post(url, map, listener);
    }

    public void pubWitness(WitnessCard card, AbResponseListener listener) {
        String url = ApiUtil.getApi(context, R.array.api_team_witness_pub);
        HttpUtils.jsonPost(url, card, listener);
    }

    public void teamCreate(Team team, AbResponseListener listener) {
        String url = ApiUtil.getApi(context, R.array.api_team_create);
        HttpUtils.jsonPost(url, team, listener);
    }

    public void getKeepDays(Long teamid, AbResponseListener listener) {
        String url = ApiUtil.getApi(context, R.array.api_keep_days, teamid);
        HttpUtils.get(url, listener);
    }


    public void targetSetting(TargetSet set , AbResponseListener listener) {
        String url = ApiUtil.getApi(context, R.array.api_target_setting,set.teamid);
        HttpUtils.jsonPost(url, set, listener);
    }

    public void suggestion(Suggestion suggestion,AbResponseListener listener)
    {
        String url=ApiUtil.getApi(context,R.array.api_suggestion);
        HttpUtils.jsonPost(url,suggestion,listener);
    }
    public void targetRecommend(TargetSet set,AbResponseListener listener)
    {
        String url=ApiUtil.getApi(context,R.array.api_target_recommend_users);
        HttpUtils.jsonPost(url,set,listener);
    }
    public void pubSubjectReply(SubjectReply reply,AbResponseListener listener)
    {
        String url=ApiUtil.getApi(context,R.array.api_pub_subject_reply,reply);
        HttpUtils.jsonPost(url,reply,listener);

    }



}
